﻿@using System.Web.Optimization
@model ScrumPilot.Domain.Models.User
@{
    ViewBag.Title = "UserView | " + Model.Name;
}
@section HeadContent{
    <link href="@Url.Content("~/Content/UserView.css")" rel="stylesheet" type="text/css" />
    @Styles.Render("~/Content/TimeLine")
}
@section AddJavaScript
{
    @Scripts.Render("~/Graph/")
    <script type="text/javascript" src=@Url.Content("~/Scripts/UserView.js")></script>
    <script type="text/javascript">
        var myPage = new UserView();
    </script>
}
@section JSDocumentReady
{
myPage.Ready();
}
@section PageOptionUrl
{
    '@Url.Action("GetWorkItems", "User")','@Url.Action("GetBugsHistory", "User")',
    '@Url.Action("GetTasksHistory", "User")','@Url.Action("GetUserHistory", "User")',
    '@Url.Action("FollowingUser", "User")'
}
@section PageOptionsOpt
{
    userId:@Model.ID
}
<div class="row-fluid">
    <div class="span2">
        <div style="margin-left: 6pt; margin-bottom: 6pt">
            <img  alt="usr" src="@Url.Action("ShowPhoto96", "AsyncData")/@Model.ID"  /><br />

        </div>
        <div class="btn-group">
            <a class="btn btn-primary" data-toggle="dropdown" href="#">Action
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
                <li>
                    @if (Model.IsCurrentUser)
                    {
                        <a href="#" onclick="return OpenDialog('dialog-upl');">Change photo</a>
                    }
                    else
                    {
                        if (!Model.Followed)
                        {
                        <a href="javascript:void(0)" data-action="0">Follow</a>
                        }
                        else
                        {
                        <a href="#" data-action="1">Unfollow</a>
                        }
                    }

                </li>
                <li><a href="@Url.Action("YammerAuthorization", "User")"><i class="icon-retweet"></i>Click here to authorize ScrumPilot to connect with your Yammer Account</a>
                </li>
            </ul>
        </div>
    </div>
    <div class="span7">
        <h2>@Model.Name</h2>
        <p>
            User Stories in progress:
            <img id="imgldw" src="~/Content/img/ajax-loader-l.gif" alt="Loading..." />
            <span id="wip"></span>
        </p>
        <p>
            Tasks in progress:
            <img id="imglts" src="~/Content/img/ajax-loader-l.gif" alt="Loading..." />
            <span id="lts"></span>
        </p>
        <p>
            Bugs in progress:
            <img id="imglbg" src="~/Content/img/ajax-loader-l.gif" alt="Loading..." />
            <span id="lbg"></span>
        </p>
        <p>
            <small>Pending changes:
                <img id="imgldp" src="~/Content/img/ajax-loader-l.gif" alt="Loading..." />
                <span id="pcs"></span></small>
        </p>
    </div>
    <div class="span3">
        <ul>
            <li class="span6 keyaccent miniKPI">
                <p id="kpiHours">0</p>
                <span class="SmallFont standardFont">Hours</span>
            </li>
            <li class="span6 keyaccent miniKPI">
                <p id="kpiScore"></p>
                <span class="SmallFont standardFont">Score</span>
            </li>
        </ul>
        <ul>
            <li class="span6 keyaccent miniKPI">
                <p id="kpiBugs"></p>
                <span class="SmallFont standardFont">Fixed bugs</span>
            </li>
            <li class="span6  keyaccent miniKPI">
                <p id="kpiTasks"></p>
                <span class="SmallFont standardFont">Done Tasks</span>
            </li>
        </ul>
    </div>
</div>
<div class="row-fluid">
    <div class="span3">
        <div id="grphBugs"></div>
        <div id="grphHours"></div>
        <div id="grphTasks"></div>
    </div>

    <ul class="span7" id="timeline-container">
    </ul>


</div>

<script id="NTimeLineTemplate" type="text/x-jsrender">
    <li>
        <h3>{{:CompleteDate}}
        </h3>
        {{for data}}
       
				  <div id="item-{{:ID}}" data-id="{{:ID}}" class="item">
                      <table style="width:100%;">
                          <tr>
                              <td class="item-wrapper span3 headofrow">
                                  <h4>{{:State}}</h4>
                              </td>
                              <td class="item-wrapper span2">
                                  <a style="width: 100%" href="{{:Url}}">{{:WorkItemType}} {{:ID}}</a><br />
                                  <abbr class="timeago" title="{{:Date}}"></abbr>
                                  <p>{{:ProjectName}}</p>
                                  <p>{{:Iteration}}</p>
                              </td>
                              <td class="item-wrapper span7">
                                  <h5>{{:Name}}</h5>
                                  <p>{{:Descriptions}}</p>
                              </td>
                          </tr>
                      </table>
                  </div>
        {{/for}}
    </li>
</script>

@*

  <table>
                          <tr class="item-header">
                              <td class="item-header-sep">
                                  <abbr class="timeago" title="{{:Date}}"></abbr>
                              </td>
                              <td class="item-header-sep">{{:State}}</td>
                              <td><a href="{{:Url}}">{{:WorkItemType}} {{:ID}}</a></td>
                          </tr>
                          <tr>
                              <td class="item-wrapper" colspan="3">
                                  <h4>{{:Name}}</h4>
                                  <p>{{:Descriptions}}</p>
                              </td>
                          </tr>
                          <tr class="item-footer">
                              <td class="item-footer-sep">{{:ProjectName}}</td>
                              <td colspan="2">{{:Iteration}}</td>
                          </tr>
                      </table>

<script id="TimeLineTemplate" type="text/x-jsrender">
    <div id="item-{{:ID}}" data-id="{{:ID}}" class="item">
        <table>
            <tr class="item-header">
                <td class="item-header-sep">
                    <abbr class="timeago" title="{{:Date}}"></abbr>
                </td>
                <td class="item-header-sep">{{:State}}</td>
                <td><a href="{{:Url}}">{{:WorkItemType}} {{:ID}}</a></td>
            </tr>
            <tr>
                <td class="item-wrapper" colspan="3">
                    <h4>{{:Name}}</h4>
                    <p>{{:Descriptions}}</p>
                </td>
            </tr>
            <tr class="item-footer">
                <td class="item-footer-sep">{{:ProjectName}}</td>
                <td colspan="2">{{:Iteration}}</td>
            </tr>
        </table>
    </div>
</script>
*@

@if (Model.IsCurrentUser)
{
    <div id="dialog-upl" title="Upload files" style="display: none">
        @using (Html.BeginForm("Upload", "User", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {
            <p>
                <input type="file" id="fileUpload" name="fileUpload" size="23" />
                @Html.Hidden("id", Model.ID)
            </p>
            <br />
            <p>
                <input type="submit" value="Upload file" />
            </p>
        }
    </div>
}